﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace DAL
{
    public static class DataAccess
    {
        const string connString = "Data Source=localhost;Initial Catalog=ChinaDB;Persist Security Info=True;User ID=sa;Password=123456";

        public static void InsertData(int id, double x, double y)
        {
            SqlConnection conn = new SqlConnection(connString);

            string strSql = String.Format("INSERT INTO dbo.tb_shp (id,x,y) VALUES({0},{1},{2})", id, x, y);

            conn.Open();

            using (conn)
            {
                SqlCommand cmd = conn.CreateCommand();

                cmd.CommandType = System.Data.CommandType.Text;
                
                cmd.CommandText = strSql;
                
                cmd.ExecuteNonQuery();
                
                cmd.Dispose();
            }

            conn.Close();
        }
    }
}
